package com.intelligentcar.springboot.controller;

import com.intelligentcar.springboot.bean.Vehicleplan;
import com.intelligentcar.springboot.service.VehicleplanServer;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@Controller
public class VehicleplanController {

    @Autowired
    private VehicleplanServer vehicleplanServerImpl;

    //车辆排班
    @RequestMapping("/vehicleSchedulinga")
    @ResponseBody
    public Map vehicleSchedulinga(HttpServletRequest req, @RequestBody Vehicleplan vehicleplan) {
        Map map = new HashMap();
        map.put("code", vehicleplanServerImpl.vehicleSchedulinga(req, vehicleplan));
        return map;
    }

    //根据车牌号查看车辆排班表中的数据
    @RequestMapping("/selectvehicleSchedulinga")
    @ResponseBody
    public Map selectvehicleSchedulinga(@RequestBody Vehicleplan vehicleplan) {
        Map map = new HashMap();
        map.put("total", vehicleplanServerImpl.countvehicleSchedulinga(vehicleplan));
        map.put("list", vehicleplanServerImpl.selectvehicleSchedulinga(vehicleplan, new RowBounds((vehicleplan.getPage() - 1) * vehicleplan.getSize(), vehicleplan.getSize())));
        return map;
    }
    //根据线路查看车辆排班表中的数据
    @RequestMapping("/selectvehicleSchedulingax")
    @ResponseBody
    public Map selectvehicleSchedulingax(@RequestBody Vehicleplan vehicleplan) {
        Map map = new HashMap();
        map.put("total", vehicleplanServerImpl.countvehicleSchedulingax(vehicleplan));
        map.put("list", vehicleplanServerImpl.selectvehicleSchedulingax(vehicleplan, new RowBounds((vehicleplan.getPage() - 1) * vehicleplan.getSize(), vehicleplan.getSize())));
        return map;
    }
    //查看车辆排班表中的所有数据
    @RequestMapping("selectVehicleplan")
    @ResponseBody
    public Map selectVehicleplan(@RequestBody Vehicleplan vehicleplan) {
        Map map = new HashMap();
        map.put("total",vehicleplanServerImpl.count());
        map.put("list", vehicleplanServerImpl.selectVehicleplan(new RowBounds((vehicleplan.getPage()-1)*vehicleplan.getSize(),vehicleplan.getSize())));
        return map;
    }

    //根据车牌号查看车辆信息表的数据
    @RequestMapping("/lookvehicleplan")
    @ResponseBody
    public Map lookvehicleplan(@RequestBody Vehicleplan vehicleplan){
        Map map = new HashMap();
        map.put("list",vehicleplanServerImpl.lookvehicleplan(vehicleplan));
        return  map ;
    }
}
